package com.lhjmall.ware.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lhjmall.ware.entity.ProductwareEntity;
import com.lhjmall.ware.service.ProductwareService;
import com.lhjmall.common.utils.PageUtils;
import com.lhjmall.common.utils.R;



/**
 *
 *
 * @author longhaijin
 * @email 287245878@qq.com
 * @date 2021-03-11 10:24:07
 */
@RestController
@RequestMapping("ware/productware")
public class ProductwareController {
    @Autowired
    private ProductwareService productwareService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("ware:productware:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = productwareService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("ware:productware:info")
    public R info(@PathVariable("id") Integer id){
		ProductwareEntity productware = productwareService.getById(id);

        return R.ok().put("productware", productware);
    }

    /**
     * 信息
     */
    @RequestMapping("/infoByProductId/{productId}")
    //@RequiresPermissions("ware:productware:info")
    public R InfoByProductId(@PathVariable("productId") Integer productId){
		ProductwareEntity productware = productwareService.getByProductId(productId);

        return R.ok().put("productware", productware);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("ware:productware:save")
    public R save(@RequestBody ProductwareEntity productware){
		productwareService.save(productware);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("ware:productware:update")
    public R update(@RequestBody ProductwareEntity productware){
		productwareService.updateById(productware);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("ware:productware:delete")
    public R delete(@RequestBody Integer[] ids){
		productwareService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
